#include <bits/stdc++.h>
using namespace std;


int n;
int chess[1010][1010] = {0};



int main(int argc, char const *argv[])
{
    freopen("五子棋.txt", "r", stdin);

    cin >> n;
    int t;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> t;
            if(t == 1) chess[i][j] = 1;
        }
    }

    // for(int i = 0; i < n; ++i){
    //     for(int j = 0; j < n; ++j)
    //         cout << chess[i][j] << " ";
    //     cout << endl;
    // }

    vector<pair<int, int>> res;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(chess[i][j] == 1) continue;

            int n_up = 0;
            while(i - n_up - 1 >= 0 && chess[i - n_up - 1][j] == 1) ++n_up;
            int n_down = 0;
            while(i + n_down + 1 < n && chess[i + n_down + 1][j] == 1) ++n_down;
            if(n_up + n_down >= 4) {
                res.emplace_back(i, j);
                continue;
            }

            int n_left = 0;
            while(j - n_left - 1 >= 0 && chess[i][j - n_left - 1] == 1) ++n_left;
            int n_right = 0;
            while(j + n_right + 1 < n && chess[i][j + n_right + 1] == 1) ++n_right;
            if(n_left + n_right >= 4) {
                res.emplace_back(i, j);
                continue;
            }

            int n_left_up = 0;
            while(i - n_left_up - 1 >= 0 && j - n_left_up - 1 >= 0 && chess[i - n_left_up - 1][j - n_left_up - 1] == 1) ++n_left_up;
            int n_right_down = 0;
            while(i + n_right_down + 1 < n && j + n_right_down + 1 < n && chess[i + n_right_down + 1][j + n_right_down + 1] == 1) ++n_right_down;
            if(n_left_up + n_right_down >= 4) {
                res.emplace_back(i, j);
                continue;
            }

            int n_right_up = 0;
            while(i - n_right_up - 1 >= 0 && j + n_right_up + 1 < n && chess[i - n_right_up - 1][j + n_right_up + 1] == 1) ++n_right_up;
            int n_left_down = 0;
            while(i + n_left_down + 1 < n && j - n_left_down - 1 >= 0 && chess[i + n_left_down + 1][j - n_left_down - 1] == 1) ++n_left_down;
            if(n_right_up + n_left_down >= 4) {
                res.emplace_back(i, j);
                continue;
            }
        }
    }

    for(auto e: res)
        cout << e.first << " " << e.second << endl;
    
    
    return 0;
}
